import { IUIContainerToolOptions, UIContainerTool } from 'babylon-lib/highly-coupled-component/gui-tool/ui-container-tool';
import * as Data from '../data/data';
import { Engine } from '@babylonjs/core/Engines/engine';
import { UINode } from 'babylon-lib/gui/base/ui-node';
import { Stage } from 'babylon-lib/index';
import { RenderOrder } from 'babylon-lib/misc/render-order';
import { NotePanel } from './note-panel';
import { Quaternion, Vector3 } from '@babylonjs/core/Maths/math.vector';
import { DEGREE } from 'babylon-lib/tool/calculation';
import { ControlPanel } from './control-panel';


class MainStageUI extends UIContainerTool {

    protected initializeStyle(options: IUIContainerToolOptions): IUIContainerToolOptions {
        const style = super.initializeStyle(options);

        style.isProduction = Data.isProduction.value;
        style.tableTitles = [];
        style.selectedTitle = '';
        style.lineHeight = 0.6;
        style.useXR = true;
        style.useDefaultXRBoot = false;
        style.backRenderingId = RenderOrder.id(Data.orders.uiBack);
        style.frontRenderingId = RenderOrder.id(Data.orders.ui);
        style.topRenderingId = RenderOrder.id(Data.orders.uiFront);

        return style;
    }

    protected onImmersive(immersive: boolean): void {
        super.onImmersive(immersive);
        NotePanel.node.rotation = Quaternion.RotationAxis(Vector3.LeftReadOnly, immersive ? -15 * DEGREE : 0);
        ControlPanel.node.rotation = Quaternion.RotationAxis(Vector3.LeftReadOnly, immersive ? -15 * DEGREE : 0);
    }

    protected initializeCustomNodes(engine: Engine, stage: Stage, style: IUIContainerToolOptions): UINode[] {
        NotePanel.initialize(stage);
        ControlPanel.initialize(stage);
        return [NotePanel.node, ControlPanel.node];
    }

}


export { MainStageUI };